/**
 ************************************************************************************************************
 * Class in charge of managin memory: at the moment, only allocation / deallocation tracking for new([]) 
 * delete ([])
 ************************************************************************************************************
 * @file RBMemoryManager.h
 ************************************************************************************************************/

#ifndef __RBMEMORYMANAGER__H__
#define __RBMEMORYMANAGER__H__

#ifdef  HEADER_ONCE
#pragma HEADER_ONCE
#endif

#ifdef  HEADER_MSG
#pragma HEADER_MSG(RBMemoryManager.h)
#endif

/************************************************************************************************************
 * Includes
 ************************************************************************************************************/
#include "RBString.h"
#include "RBMemoryTracker.h"

/************************************************************************************************************
 * Forward declarations
 ************************************************************************************************************/

/************************************************************************************************************
 * Class
 ************************************************************************************************************/

class RBMemoryManager
{
public:

    enum EAllocType
    {
        MAT_NEW = 0,
        MAT_NEWARRAY,
    };
	
    static bool        TrackMemory;
    static void*       Allocate            (size_t stSize, EAllocType eAllocType);
    static void        Deallocate          (void* pAddress, EAllocType eAllocType);
    
    static void        SetOwner            (const char* pcFile, int iLine, const char* pcFunc);
	
    static bool        HasMemLeaks         ();
    static RBString    GetLeaksDescription ();

private:

#if RB_USE_MEMORY_MANAGER
    static RBMemoryTracker ms_Tracker;

    static uint32 ms_AllocatedObjects;
    static uint32 ms_uiAllocID;
#endif
};

/************************************************************************************************************/

#endif // __RBMEMORYMANAGER__H__
